Skip to content

Port the pager to current Textual - #154

Open
pattems wants to merge 1 commit into
Textualize:mainfrom
pattems:py313-port-the-pager-to-current-textual
Open

pattems wants to merge 1 commit into
Textualize:mainfrom
pattems:py313-port-the-pager-to-current-textual

Conversation

@pattems

@pattems pattems commented Oct 29, 2026

Copy link
Copy Markdown

rich-cli pins textual (>=0.1.18,<0.2.0) because pager.py uses the Textual 0.1 API (textual.widgets.ScrollView, App.run() as a class method, view.dock()), and textual 0.1 in turn holds rich-cli to rich <13. With those pins rich-cli cannot be installed next to anything that uses a current Rich or Textual (#75, #128), and distributions that ship one Textual (e.g. 8.x) cannot use the --pager mode at all: from textual.widgets import ScrollView raises ImportError.

This rewrites PagerApp on the current API:

  • PagerView is a focusable ScrollableContainer holding a Static with the pre-rendered PagerRenderable (unchanged).
  • The existing keys become bindings: q quits, j/k scroll one line, space pages down, ctrl+d/ctrl+u scroll half a page; the container adds arrows, page up/down, home and end.
  • __main__.py now does PagerApp(content=..., title=resource).run().
  • Dependencies: textual (>=1.0.0), rich (>=13.3.3) (Textual 1.0's minimum). CHANGELOG updated.

poetry.lock is not regenerated in this PR; it needs a poetry lock after merging (or I can add it if you prefer).

Testing

Headless test with App.run_test() (80x24) on a 300-line Syntax render: checks the view gets focus, then presses j j j k space ctrl+d ctrl+u end home and checks scroll_y after each (1, 2, 3, 2, 25, 37, 25, max, 0), then q.

Python textual / rich result
3.12.13 8.2.8 / 15.0.0 OK
3.13.14 8.2.8 / 15.0.0 OK
3.14.3 8.2.8 / 15.0.0 OK
3.13.14 1.0.0 / 13.3.3 (minimums) OK

Also on 3.12/3.13/3.14 with rich 15.0.0: pytest tests (1 passed), and rich FILE --force-terminal for README.md and every file in test_data/ (csv, ipynb, rst), plus rich --print ... --export-svg, all without errors. The interactive pager itself was not driven in a real terminal.

Context

Found while testing packages against Python 3.13 for FreeBSD ports (https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=292105).

The pager was written for Textual 0.1 (ScrollView, App.run() as a
class method, view.dock()), so rich-cli pinned textual <0.2 and, through
it, rich <13. Those pins make rich-cli impossible to install next to
anything that uses a current Rich or Textual.

Rewrite PagerApp on top of ScrollableContainer and a Static holding the
pre-rendered lines. The existing keys are kept as bindings (q to quit,
j/k for one line, space for a page, ctrl+d/ctrl+u for half a page), and
the container adds the arrow, page up/down, home and end keys.

Require textual >= 1.0.0 and rich >= 13.3.3 (the minimum Rich of
Textual 1.0).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant